# coding:utf-8

from rest_framework.views import exception_handler
from rest_framework.response import Response


def custom_exception_handler(exc, context):
    response = exception_handler(exc, context)

    if response is not None and response.status_code == 404:
        # If the response status code is 404, modify it to return the last page
        response = Response({"data": [], "code": 404, "success": False, "msg": "资源不存在或已删除！"}, status=200)

    return response
